var v_script_id = 'authroleinfos_3';
//脚本状态,0:该脚本不许执行，1:该脚本可以执行
var v_status = '1';
//脚本逻辑写在run语句之间
if (run && action.getAuthority().is(5,"9")){
	var user = action.getSession().getAttribute("user");
	var authid = action.form.getInteger('authid');
	var checkids_roles = action.form.getString('checkids_roles');
	var checkids_kinds = action.form.getString('checkids_kinds');
	//h_auth_role_infos
	var arrkinds = checkids_kinds.split(',');
	var arrrole =  checkids_roles.split(',');
	for(i=0; i<arrkinds.length; i++){
		for(j=0; j<arrrole.length; j++){
			sql = "select count(id) from h_auth_role_infos where authid = " + 
					authid + " and authkind = " + arrkinds[i] + " and roleid = " + arrrole[j] ;
			if( action.dbUtil.getSampleIntegerValue(sql) == 0 ){
				sql = "insert into h_auth_role_infos(id,authid,authkind,roleid) " +
					" values(h_auth_role_info_seq.nextval,"+authid+","+arrkinds[i]+","+arrrole[j]+")";
				if(action.dbUtil.update("",sql)==0) 
				{
					action.errorCode = 2;//数据库操作失败
					action.retString = '数据库操作失败';//错误文字说明
				}
			}
		} 
	}
	//刷新权限分配缓存
	if (action.errorCode ==0){
		com.handy.plugin.auth.TAuthCache.getInstance().loadAuthRoleInfos();
	}
	 
}